package com.freewater.library.catalogue.application.command;

import com.freewater.library.common.domain.Command;
import com.freewater.library.common.domain.Nullable;
import lombok.Getter;
import lombok.ToString;
import org.apache.commons.lang3.Validate;

import java.math.BigDecimal;
import java.time.LocalDate;

@Getter
@ToString
public class CreateBookCommand implements Command {
    /**
     * ISBN
     */
    private final String isbn;
    /**
     * 标题
     */
    private final String title;
    /**
     * 副标题
     */
    private final String subtitle;
    /**
     * 作者
     */
    private final String author;
    /**
     * 出版社
     */
    private final String publishingHouse;
    /**
     * 出版日期
     */
    private final LocalDate publicationDate;
    /**
     * 封面图
     */
    private final String cover;
    /**
     * 定价
     */
    private final BigDecimal listPrice;
    /**
     * 页数
     */
    private final Integer pageCount;
    /**
     * 装帧
     */
    private final String bindingAndLayout;
    /**
     * 丛书
     */
    private final String series;
    /**
     * 介绍/描述
     */
    private final String description;

    public CreateBookCommand(String isbn,
                             String title,
                             @Nullable String subtitle,
                             @Nullable String author,
                             @Nullable String publishingHouse,
                             @Nullable LocalDate publicationDate,
                             @Nullable String cover,
                             @Nullable BigDecimal listPrice,
                             @Nullable Integer pageCount,
                             @Nullable String bindingAndLayout,
                             @Nullable String series,
                             @Nullable String description) {
        Validate.notBlank(isbn, "ISBN不能为空");
        Validate.notBlank(title, "标题不能为空");
        this.isbn = isbn;
        this.title = title;
        this.subtitle = subtitle;
        this.author = author;
        this.publishingHouse = publishingHouse;
        this.publicationDate = publicationDate;
        this.cover = cover;
        this.listPrice = listPrice;
        this.pageCount = pageCount;
        this.bindingAndLayout = bindingAndLayout;
        this.series = series;
        this.description = description;
    }
}
